#define  _CRT_SECURE_NO_WARNINGS
#include <vector>
using namespace std;
#include <algorithm>
#include <unordered_set>
class Solution {
public:
    int MLS(vector<int>& arr1) {
        unordered_set<int> set1(arr1.begin(), arr1.end());
        vector<int> arr(set1.begin(), set1.end());
        sort(arr.begin(), arr.end());
        int ret = 1;
        for (int i = 0; i < arr.size() - 1; i++)
        {
            int tmp = 1;
            while (i < arr.size() - 1 && arr[i] + 1 == arr[i + 1])
            {
                tmp++;
                i++;
            }
            ret = max(ret, tmp);
        }
        return ret;
    }
};
#include <unordered_map>
class Solution {
public:
    int MLS(vector<int>& arr) {
        int ret = 1;
        unordered_map<int, int> map1;
        for (int i = 0; i < arr.size(); i++)
        {
            map1[arr[i]] = map1[arr[i] - 1] + 1;
            ret = max(ret, map1[arr[i]]);
        }
        return ret;
    }
};